<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<div th:include="comm/head :: login_resource"></div>
<body class="layui-login">
<form method="post" class="layui-form">
    <div class="login-wrap">
        <div class="login-logo"></div>
        <div class="login-form" style="padding: 20px 30px">
            <div class="col">
                <input name="username" placeholder="用户名" type="text" lay-verify="required" class="login-input">
                <label class="icon user"  ></label>
            </div>
            <div class="col">
                <input name="password" lay-verify="required" placeholder="密码" type="password" class="login-input">
                <label class="icon pwd" ></label>
            </div>
            <div class="col">
                <input type="submit" value="登录" lay-submit lay-filter="login" class="login-btn" />
            </div>
        </div>
    </div>
    <div class="Footer" style="margin-top: 50px; color: #fff;font-size:16px">
        Copyright©2019-2020, 本系统由@一如既往，提供技术支持！
    </div>
    <div class="Footer" style="margin-top: 5px; color: #fff;font-size:14px">
        <a href="#" style="color:#fff" target="_blank">备案/许可证编号为：XXXX</a>
    </div>
</form>

<script>
    $(function () {
        layui.use('form', function () {
            var form = layui.form;
            form.on('submit(login)', function (data) {
                console.log("---------"+JSON.stringify(data))
                $.ajax({
                    type: "POST",
                    url: '../login',
                    data: data.field,
                    dataType: "json",
                    success: function(data){
                        console.log(data.msg);
                        if(data.code==0){
                            layer.msg(data.msg);
                            window.location.href = 'sysIndex';
                        }else{
                            layer.msg(data.msg);
                        }
                    }
                });
                return false;
            });
        });
    })
</script>
</body>

<!--
<body> &lt;!&ndash; 背景图片样式 style="background: url(${ctxStatic}/public/image/login_img.jpg) no-repeat top center;background-size: cover;-webkit-background-size: cover;-o-background-size: cover;height: 100%;width: 100%;position: fixed;"> &ndash;&gt;
<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">
    <div class="layadmin-user-login-main">
        <div class="layadmin-user-login-box layadmin-user-login-header">
            <h2>权限管理系统</h2>
            <p>SPRINGBOOT-AUTH</p>
        </div>
        <form class="layui-form-item-login layui-form" id="infoForm">
            <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
                <div class="layui-form-item">
                    <label class="layadmin-user-login-icon layui-icon layui-icon-username" for="LAY-user-login-username"></label>
                    <input type="text" name="username" id="LAY-user-login-username" lay-verify="required" placeholder="用户名" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
                    <input type="password" name="password" id="LAY-user-login-password" lay-verify="required" placeholder="密码" class="layui-input"
                </div>
                <div class="layui-form-items" style="margin-bottom: 20px;">
                    <input type="checkbox" name="isRememberMe" id="LAY-user-login-remember" title="记住密码" lay-skin="primary">
                </div>
                <div class="layui-form-item">
                    <button type="button" class="layui-btn layui-btn-normal layui-btn-fluid signIn" lay-submit lay-filter="LAY-user-login-submit">登录</button>
                </div>
            </div>
        </form>
    </div>
</div>



<script type="text/javascript" th:src="@{/public/layui/layer/layer.js}"></script>
<script type="text/javascript" th:src="@{/public/layui/layui.all.js}"></script>
<script>
var cookies = document.cookie.split(";");
function getCK(mKey){
	for(var i=0;i<cookies.length;i++){
		var kv = cookies[i].split("=");
		if(kv[0].trim()==mKey){
			return kv[1].trim();
		}
	}
}
window.onload = function () {
	   if (window.parent.window != window) {  
	       window.top.location = "/";
	   }
	   var isRememberMe = getCK("isRememberMe");
	   var username = getCK("username");
	   var password = getCK("password");
	   if(isRememberMe=="on" && username!=null && username!=''){
		   var usernameInput = document.getElementById("LAY-user-login-username");
		   var passwordInput = document.getElementById("LAY-user-login-password");
		   var isRememberMeInput = document.getElementById("LAY-user-login-remember");
		   usernameInput.value=username;
		   passwordInput.value=password;
		   isRememberMeInput.checked = "checked"; 
		   layui.use(['form'], function() {
			   form = layui.form;
			   form.render("checkbox");
		   });
	   }
} 

	$(function() {
		$(".signIn").click(function(){
			var name = $("#LAY-user-login-username").val();
			var pwd  = $("#LAY-user-login-password").val();
			if (name=='') {
				layer.msg('请输入用户名');
		   		return false;
			}
			if (pwd=='') {
				layer.msg('请输入密码');
			    return false;
			}
			$('#infoForm').ajaxSubmit({
					type : 'post',
					url : 'login',//根据自己接口更改
			        beforeSend: function(){
			            this.layerIndex = layer.load(1, {shade: [0.9,'xe63d']});
			        },
			        complete: function(){
			            layer.close(this.layerIndex);
			        } ,
			    	dataType: "json",
			       	success : function(data){
			       	console.log(data.msg);
		            if(data.code==0){ 
		               layer.msg(data.msg);
		               window.location.href = 'sysIndex';
		            }else{ 
		                 layer.msg(data.msg);
		            }
		        } 
			})
		})
	})
  </script>
</body>-->
</html>